package com.taotao.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.content.service.ContentCategoryService;

import pojo.EasyUITreeNode;
import pojo.TaotaoResult;

@Controller
@RequestMapping("/content/category")
public class ContentCategoryController {
	//內容分类管理例表显示
	@Autowired
	private ContentCategoryService contentCategoryService;
	@RequestMapping("/list")
	@ResponseBody
	public List<EasyUITreeNode> getContentCategoryList(@RequestParam(value="id",defaultValue="0")long parentId){
		 List<EasyUITreeNode> list = contentCategoryService.getContentCategoryList(parentId);
		 return list;
	}
	//后台内容分类管理新增 
	@RequestMapping("/create")
	@ResponseBody
	public TaotaoResult createCategory(Long parentId, String name) {
		return contentCategoryService.addContentCategory(parentId, name);
	}
	//后台内容分类管理修改名字 
	@RequestMapping("/update")
	@ResponseBody
	public TaotaoResult updateContentCategory(long id, String name) {
		return contentCategoryService.updateContentCategory(id, name);
	}
}
